#include <REGX52.H>
#include "Delay.h"

//获取独立按键的键码，按下按键后返回按键键码0~4，无按键按下时则为0
unsigned char Key()
{
	unsigned char KeyNumber=0;
	
	if(P3_1==0){Delay1ms(20);while(P3_1==0);Delay1ms(20);KeyNumber=1;}
	if(P3_0==0){Delay1ms(20);while(P3_0==0);Delay1ms(20);KeyNumber=2;}
	if(P3_2==0){Delay1ms(20);while(P3_2==0);Delay1ms(20);KeyNumber=3;}
	if(P3_3==0){Delay1ms(20);while(P3_3==0);Delay1ms(20);KeyNumber=4;}
	
	return KeyNumber;
}